package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsFootprintMapper;
import com.qf.pojo.DtsFootprint;
import com.qf.service.FootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class FootprintServiceImpl implements FootprintService {

    @Autowired
    private DtsFootprintMapper dtsFootprintMapper;

    @Override
    public IPage<DtsFootprint> findListByQuery(Integer page, Integer limit, Integer userId, Integer goodsId, String sort, String order) {
        return dtsFootprintMapper.selectPage(new Page<>(page,limit),new QueryWrapper<DtsFootprint>()
                .eq(userId!=null,"user_id",userId)
                .eq(goodsId!=null,"goods_id",goodsId)
                .eq("deleted",false)
                .orderBy(!StringUtils.isEmpty(sort),"ASC".equalsIgnoreCase(order),sort));
    }
}
